//数据收集，跨域处理中间件
module.exports = options => {
    return (ctx, next) => {
        ctx.set({
            'Access-Control-Allow-Origin': '*',
            "Access-Control-Allow-Headers": 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With',
            "Access-Control-Allow-Methods": "PUT,POST,GET,DELETE,OPTIONS",
        });

        if (ctx.method === "OPTIONS") {
            ctx.body = 'allow access';
            return false;
        }

        return next();

    }
};